unit uIndice;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Mask, DBCtrls, Buttons, ExtCtrls, XPMenu, FMTBcd, DB,
  DBClient, Provider, SqlExpr, ToolEdit, CurrEdit, JvExStdCtrls, JvEdit,
  JvValidateEdit, JvExMask, JvToolEdit, JvBaseEdits, DBXpress;

type
  TfIndice = class(TForm)
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Panel2: TPanel;
    BitBtn3: TBitBtn;
    Label1: TLabel;
    XPMenu1: TXPMenu;
    DataSource1: TDataSource;
    cds_ht: TClientDataSet;
    dsp_ht: TDataSetProvider;
    sds_ht: TSQLDataSet;
    sds_htCOD_LANCAMENTO: TIntegerField;
    sds_htCOD_FIXOS: TIntegerField;
    sds_htCOD_IMALU: TIntegerField;
    sds_htCOD_CONTAS: TIntegerField;
    sds_htQUTDE: TIntegerField;
    sds_htVALOR: TFloatField;
    sds_htVALOR_TOTAL: TFloatField;
    sds_htDESCRICAO: TStringField;
    sds_htPARCELA: TIntegerField;
    sds_htVENCIMENTO: TDateField;
    sds_htDATA_LANC: TDateField;
    sds_htCOD_INQUILINO: TIntegerField;
    sds_htCOD_MOVIMENTO: TIntegerField;
    sds_htCOD_PROPRIETARIO: TIntegerField;
    sds_htVIA: TStringField;
    sds_htGRUPO: TStringField;
    sds_htTIPOCONTA: TStringField;
    sds_htSTATUS: TStringField;
    sds_htFORMAPGTO_RECEBTO: TStringField;
    sds_htN_DOCUMENTO: TStringField;
    cds_htCOD_LANCAMENTO: TIntegerField;
    cds_htCOD_FIXOS: TIntegerField;
    cds_htCOD_IMALU: TIntegerField;
    cds_htCOD_CONTAS: TIntegerField;
    cds_htQUTDE: TIntegerField;
    cds_htVALOR: TFloatField;
    cds_htVALOR_TOTAL: TFloatField;
    cds_htDESCRICAO: TStringField;
    cds_htPARCELA: TIntegerField;
    cds_htVENCIMENTO: TDateField;
    cds_htDATA_LANC: TDateField;
    cds_htCOD_INQUILINO: TIntegerField;
    cds_htCOD_MOVIMENTO: TIntegerField;
    cds_htCOD_PROPRIETARIO: TIntegerField;
    cds_htVIA: TStringField;
    cds_htGRUPO: TStringField;
    cds_htTIPOCONTA: TStringField;
    cds_htSTATUS: TStringField;
    cds_htFORMAPGTO_RECEBTO: TStringField;
    cds_htN_DOCUMENTO: TStringField;
    Edit1: TJvCalcEdit;
    sImovel: TSQLDataSet;
    sImovelCOD_IMALU: TIntegerField;
    sImovelIMOVEL: TStringField;
    sImovelTIPO: TStringField;
    sImovelCOD_PROPRIETARIO: TIntegerField;
    sImovelCOD_INQUILINO: TIntegerField;
    sImovelCOD_FUNCIONARIO: TIntegerField;
    sImovelCOD_ENDERECO: TIntegerField;
    sImovelNR: TStringField;
    sImovelCOMPL: TStringField;
    sImovelMATRICULA: TStringField;
    sImovelDATA_REGISTRO: TDateField;
    sImovelDETALHES: TStringField;
    sImovelVALOR_ALUGUEL: TFloatField;
    sImovelVALOR_EXTENCO: TStringField;
    sImovelALUGADO: TStringField;
    sImovelMESES: TStringField;
    sImovelDIAPGTO: TStringField;
    sImovelCARENCIA: TStringField;
    sImovelDATA_AQUIZICAO: TStringField;
    sImovelDATA_LOCACAO: TStringField;
    sImovelDATA_VCONTRATO: TStringField;
    sImovelN_QUARTOS: TStringField;
    sImovelN_SALAS: TStringField;
    sImovelN_COZINHAS: TStringField;
    sImovelN_GARAGENS: TStringField;
    sImovelOBS: TStringField;
    sImovelCOMISSAO_IMOBILIARIA: TFloatField;
    sImovelCOD_IMOBILIARIA: TStringField;
    sImovelDATA_LOCA: TDateField;
    sImovelDATA_VCONT: TDateField;
    sImovelATIVO: TStringField;
    sImovelPORCENTUAL: TFloatField;
    sImovelTAXA_ADM: TFloatField;
    sImovelMETRAGEM: TStringField;
    sImovelBAIRRO: TStringField;
    sImovelCIDADE: TStringField;
    sImovelCEP: TStringField;
    sImovelUF: TStringField;
    sImovelPRAZO_REPASSE: TIntegerField;
    sImovelFORMA_REPASSE: TStringField;
    sImovelFORMA_RECEBE: TStringField;
    sImovelVISITA: TStringField;
    sImovelCOD_INTERESSADO: TIntegerField;
    sImovelDATAVISITA: TDateField;
    s_inquilino: TSQLDataSet;
    p_inquilino: TDataSetProvider;
    c_inquilino: TClientDataSet;
    c_inquilinoCOD_LANCAMENTO: TIntegerField;
    c_inquilinoCOD_FIXOS: TIntegerField;
    c_inquilinoCOD_IMALU: TIntegerField;
    c_inquilinoCOD_CONTAS: TIntegerField;
    c_inquilinoQUTDE: TIntegerField;
    c_inquilinoVALOR: TFloatField;
    c_inquilinoVALOR_TOTAL: TFloatField;
    c_inquilinoDESCRICAO: TStringField;
    c_inquilinoPARCELA: TIntegerField;
    c_inquilinoVENCIMENTO: TDateField;
    c_inquilinoDATA_LANC: TDateField;
    c_inquilinoCOD_INQUILINO: TIntegerField;
    c_inquilinoCOD_MOVIMENTO: TIntegerField;
    c_inquilinoCOD_PROPRIETARIO: TIntegerField;
    c_inquilinoVIA: TStringField;
    c_inquilinoGRUPO: TStringField;
    c_inquilinoTIPOCONTA: TStringField;
    c_inquilinoSTATUS: TStringField;
    c_inquilinoFORMAPGTO_RECEBTO: TStringField;
    c_inquilinoN_DOCUMENTO: TStringField;
    c_inquilinoDATAPAGTO: TDateField;
    c_inquilinoSELECIONOU: TStringField;
    c_inquilinoVALORPAGO: TFloatField;
    c_inquilinoVALORTROCO: TFloatField;
    s_inquilinoCOD_LANCAMENTO: TIntegerField;
    s_inquilinoCOD_FIXOS: TIntegerField;
    s_inquilinoCOD_IMALU: TIntegerField;
    s_inquilinoCOD_CONTAS: TIntegerField;
    s_inquilinoQUTDE: TIntegerField;
    s_inquilinoVALOR: TFloatField;
    s_inquilinoVALOR_TOTAL: TFloatField;
    s_inquilinoDESCRICAO: TStringField;
    s_inquilinoPARCELA: TIntegerField;
    s_inquilinoVENCIMENTO: TDateField;
    s_inquilinoDATA_LANC: TDateField;
    s_inquilinoCOD_INQUILINO: TIntegerField;
    s_inquilinoCOD_MOVIMENTO: TIntegerField;
    s_inquilinoCOD_PROPRIETARIO: TIntegerField;
    s_inquilinoVIA: TStringField;
    s_inquilinoGRUPO: TStringField;
    s_inquilinoTIPOCONTA: TStringField;
    s_inquilinoSTATUS: TStringField;
    s_inquilinoFORMAPGTO_RECEBTO: TStringField;
    s_inquilinoN_DOCUMENTO: TStringField;
    s_inquilinoDATAPAGTO: TDateField;
    s_inquilinoSELECIONOU: TStringField;
    s_inquilinoVALORPAGO: TFloatField;
    s_inquilinoVALORTROCO: TFloatField;
    s_proprietario: TSQLDataSet;
    p_proprietario: TDataSetProvider;
    c_proprietario: TClientDataSet;
    c_proprietarioCOD_LANCAMENTO: TIntegerField;
    c_proprietarioCOD_FIXOS: TIntegerField;
    c_proprietarioCOD_IMALU: TIntegerField;
    c_proprietarioCOD_CONTAS: TIntegerField;
    c_proprietarioQUTDE: TIntegerField;
    c_proprietarioVALOR: TFloatField;
    c_proprietarioVALOR_TOTAL: TFloatField;
    c_proprietarioDESCRICAO: TStringField;
    c_proprietarioPARCELA: TIntegerField;
    c_proprietarioVENCIMENTO: TDateField;
    c_proprietarioDATA_LANC: TDateField;
    c_proprietarioCOD_INQUILINO: TIntegerField;
    c_proprietarioCOD_MOVIMENTO: TIntegerField;
    c_proprietarioCOD_PROPRIETARIO: TIntegerField;
    c_proprietarioVIA: TStringField;
    c_proprietarioGRUPO: TStringField;
    c_proprietarioTIPOCONTA: TStringField;
    c_proprietarioSTATUS: TStringField;
    c_proprietarioFORMAPGTO_RECEBTO: TStringField;
    c_proprietarioN_DOCUMENTO: TStringField;
    c_proprietarioDATAPAGTO: TDateField;
    c_proprietarioSELECIONOU: TStringField;
    c_proprietarioVALORPAGO: TFloatField;
    c_proprietarioVALORTROCO: TFloatField;
    s_proprietarioCOD_LANCAMENTO: TIntegerField;
    s_proprietarioCOD_FIXOS: TIntegerField;
    s_proprietarioCOD_IMALU: TIntegerField;
    s_proprietarioCOD_CONTAS: TIntegerField;
    s_proprietarioQUTDE: TIntegerField;
    s_proprietarioVALOR: TFloatField;
    s_proprietarioVALOR_TOTAL: TFloatField;
    s_proprietarioDESCRICAO: TStringField;
    s_proprietarioPARCELA: TIntegerField;
    s_proprietarioVENCIMENTO: TDateField;
    s_proprietarioDATA_LANC: TDateField;
    s_proprietarioCOD_INQUILINO: TIntegerField;
    s_proprietarioCOD_MOVIMENTO: TIntegerField;
    s_proprietarioCOD_PROPRIETARIO: TIntegerField;
    s_proprietarioVIA: TStringField;
    s_proprietarioGRUPO: TStringField;
    s_proprietarioTIPOCONTA: TStringField;
    s_proprietarioSTATUS: TStringField;
    s_proprietarioFORMAPGTO_RECEBTO: TStringField;
    s_proprietarioN_DOCUMENTO: TStringField;
    s_proprietarioDATAPAGTO: TDateField;
    s_proprietarioSELECIONOU: TStringField;
    s_proprietarioVALORPAGO: TFloatField;
    s_proprietarioVALORTROCO: TFloatField;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fIndice: TfIndice;

implementation

uses uReceber, UDM, uReajuste, uProcurar, uFiltra_Aluguel, uContasReceber;

{$R *.dfm}

procedure TfIndice.BitBtn1Click(Sender: TObject);
var
  a, b, c, d, indice, valor :Double;
  varVenc, e, varsql:String;
  f, varCodigoCliente, varCodigoProprietario : integer;
  TD: TTransactionDesc;
begin
    TD.TransactionID := 1;
    TD.IsolationLevel := xilREADCOMMITTED;
    dm.scSge.StartTransaction(TD);
    varsql := 'EXECUTE PROCEDURE indice_reaj (';
    varsql := varsql + IntToStr(dm.vCod_imo) + ', ';
    varsql := varsql + IntToStr(dm.vCod_inq) + ', ';
    varsql := varsql + IntToStr(dm.vCod_pro) + ', ';
    varsql := varsql + IntToStr(dm.vParcela) + ', ';
    DecimalSeparator := '.';
    varsql := varsql + FloatToStr(dm.vValAluguel) + ', ';
    varsql := varsql + FloatToStr(dm.vTaxaAdm) + ', ';
    varsql := varsql + FloatToStr(Edit1.Value) + ', ';
    DecimalSeparator := ',';
    varsql := varsql + QuotedStr(FormatDateTime('MM/dd/yyyy', dm.vData_loca)) + ', ';
    varsql := varsql + QuotedStr(FormatDateTime('MM/dd/yyyy', dm.vData_vcont)) + ',';
    varsql := varsql + QuotedStr(FormatDateTime('MM/dd/yyyy', Now)) + ')';
    DM.scSge.ExecuteDirect(varsql);
    dm.scSge.Commit(TD);
    fReajuste.Close;
    findice.Close;
end;

procedure TfIndice.BitBtn2Click(Sender: TObject);
begin
close;
end;

procedure TfIndice.BitBtn3Click(Sender: TObject);
begin

  FProcurar:=TFProcurar.Create(Self,dm.cds_procIndice);
  try
   FProcurar.BtnProcurar.Click;
   fProcurar.EvDBFind1.DataField := 'DATA';
   if FProcurar.ShowModal=mrOK then
  begin
   Edit1.Text := dm.cds_procIndiceINDICE.AsString;
  end;
  finally
   DM.cds_procIndice.Close;
   FProcurar.Free;
  end;

end;

end.
